class Solution {
    public double myPow(double x, int n) {
        return n < 0 ? 1 / pow(x, -n) : pow(x, n);
    }
    public double pow(double x, int n) {
        if(n == 0) return 1;

        //宏观角度看待递归，得到当前数n/2幂的值
        double tmp = pow(x, n / 2);
        
        return (n % 2 == 0) ? tmp * tmp : tmp * tmp * x;
    }
}